package com.qidian.permission.controller;

import com.qidian.permission.entity.Role;
import com.qidian.permission.entity.User;
import com.qidian.permission.service.RoleService;
import com.qidian.permission.service.UserService;
import com.qidian.permission.util.PerResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 32郗建狄
 * @Company GX631
 * Time 2023/10/18 18:18
 * Description
 */
@RestController
@RequestMapping("/role")
@CrossOrigin
public class RoleController {
    @Autowired
    RoleService roleService;

    @RequestMapping("/selectById")
    public PerResult selectById(Long roleId){
        return roleService.selectById(roleId);
    }
    @PostMapping("/addRole")
    public PerResult addUser(@RequestBody Role role){
        return roleService.addRole(role);
    }
    @RequestMapping("/list")
    public PerResult list(Role role, @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int limit){
        return roleService.selectByPage(role,page,limit);
    }
    @PutMapping("/update")
    public PerResult update(@RequestBody Role role){
        return roleService.update(role);
    }
    @DeleteMapping("/delete")
    public PerResult delete(Long roleId){
        return roleService.deleteByRoleId(roleId);
    }
    @DeleteMapping("/deletes")
    public PerResult deletes(Long[] roleId){
        return roleService.deletesByRoleId(roleId);
    }
}
